<template>
	<view class="content">
		<navTop :title="navtop.title" :isHeight="false" :tipsShow="false" hasBgc="#fff" :color="navtop.color" :isBack="true" ></navTop>
		<view class="content-box" :style="{paddingTop:barHeight+'rpx'}">
			<view class="content-title">{{title}}</view>
			<video id="video_play" 
				class="response" 
				:src="videoUrl"
				:title="title"
				controls="true"
				page-gesture="true"
				object-fit="contain"
				show-mute-btn="true"
				enable-play-gesture="true"
				vslide-gesture="true"
				@play="playVedio()"
				@error="videoErrorCallback" 
				@waiting="videoWaiting"
				@loadedmetadata="videoLoadOk"
			></video>
		</view>
		<view class="content-body">
		</view>
	</view>
</template>
<script>
import navTop from '@/components/nav-title.vue';
import iconAdd from '@/static/icon_add.png';

	export default {
		components: {
			navTop
		},
		data() {
			return {
				iconAdd,
				barHeight: 0,
				navtop: {
					title: 'Video Detail',
					color: '#000'
				},
				videoUrl: '',
				imgUrl: '',
				title: ''
			}
		},
		onLoad(e) {
			console.log(e.id)
			this.getVideo(e.id)
		},
		created() {
			this.isBarHeight999().then((statusBarHeight)=>{
				this.barHeight = statusBarHeight + 140
			})
		},
		mounted() {
		},
		methods: {
			getVideo(id) {
				this.$http('get', '/app/video/getById', {
					id
				}).then(res => {
					if (res.success) {
						this.videoUrl = res.data.videoUrl;
						this.imgUrl = res.data.imgUrl;
						this.title = res.data.title;
					}
				})
			},
			setVideoUrl() {
				console.log(this.videoSrc)
				// uni.setNavigationBarTitle({
				// 	title: this.title
				// });
				this.videoUrl = this.videoSrc;
				this.firstImg = this.firstPic;
				this.videoTitle = this.title;
				
				console.log(this.firstImg + '___' + this.firstPic)
				
				console.log(this.title + '___' + this.videoTitle)
			},
			videoErrorCallback(e) {
				uni.showModal({
					content: e.target.errMsg,
					showCancel: false
				});
			},
			videoWaiting() {
				// uni.showLoading({
				//     title: '加载中'
				// });
			},
			videoLoadOk() {
				 // uni.hideLoading();
			},
			playVedio(){
                // 获取 video 上下文 videoContext 对象
                this.videoContext = uni.createVideoContext('video_play');
                // 进入全屏状态
                this.videoContext.requestFullScreen();
			
			}
		}
	}
</script>

<style lang="less">
.content {
	background-color: #FBFCFE;
	// padding: 0 30px;
	min-height: 100vh;
}
.content-box {
	font-size: 40rpx;
	font-family: Helvetica-Bold, Helvetica;
	font-weight: bold;
	color: #1F1F1F;
	text-align: center;
	margin-bottom: 34rpx;
	.content-title {
		font-size: 40rpx;
		padding: 28rpx 30rpx;
		background-color: #fff;
		width: 100%;
		box-sizing: border-box;
	}
}

.content-body{
	padding: 0 30rpx;
	margin-top: 40rpx;
	z-index: 999;
}
.content-body__img {
	width: 336rpx;
	height: 192rpx;
	border-radius: 20rpx;
}

.content-body__text {
	display: block;
	width: 100%;
	font-size: 28rpx;
	padding: 24rpx;
	font-family: Helvetica;
	color: #1F1F1F;
	text-overflow: -o-ellipsis-lastline;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
}
.content-body__bg {
	width: 192rpx;
	height: 192rpx;
	position: absolute;
	right: 0;
	top: 0;
}
#video_play {
	width: 100%;
	margin: 10rpx auto;
}
</style>
